﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.IO;

namespace MikroTransfer
{
    public partial class frmDepoEslestir : XtraForm
    {
        public frmDepoEslestir()
        {
            InitializeComponent();
        }

        private void frmDepoEslestir_Load(object sender, EventArgs e)
        {
            if (File.Exists(Application.StartupPath + "\\nokia_depo_eslestirme.txt"))
            {
                using (StreamReader sr = new StreamReader(Application.StartupPath + "\\nokia_depo_eslestirme.txt"))
                {
                    string line = "";
                    int row = 1;
                    while (sr.Peek() > -1)
                    {
                        line = sr.ReadLine();
                        string[] dizi = line.Split(';');
                        c1FlexGrid1[row, 0] = dizi[0];
                        c1FlexGrid1[row, 1] = dizi[1];
                        c1FlexGrid1[row, 2] = dizi[2];
                        row++;
                    }
                    sr.Close();
                }
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            using (StreamWriter sw = new StreamWriter(Application.StartupPath + "\\nokia_depo_eslestirme.txt", false))
            {
                for (int i = 1; i < c1FlexGrid1.Rows.Count; i++)
                {
                    if (c1FlexGrid1[i, 0] != null && !string.IsNullOrEmpty(c1FlexGrid1[i, 0].ToString()) && c1FlexGrid1[i, 1] != null && c1FlexGrid1[i, 2] != null)
                    {
                        sw.WriteLine(string.Format("{0};{1};{2}", c1FlexGrid1[i, 0], c1FlexGrid1[i, 1], c1FlexGrid1[i, 2]));
                    }
                }
                sw.Close();
            }
            this.Close();
        }
    }
}

